<div class="container-fluid" ng-controller="sysAccountCtrl">
    <!-- Page Heading -->
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">
                管理员
                <small>管理</small>
            </h1>
        </div>
    </div>
    <!-- /.row -->
    <div class="row">
        <div class="col-lg-12">
            <div id="toolbar" class="btn-group">
                <button id="accountCreate" type="button" class="btn btn-primary" data-toggle="modal" >新增帐号</button>
            </div>
            <table <table id="table" data-toggle="table" data-pagination="true" data-toggle="table" data-search="true" data-show-refresh="true"
                data-show-toggle="true" data-show-columns="true" data-toolbar="#toolbar">
                <thead>
                    <tr>
                        <th data-field="userName">帐号名称</th>
                        <th data-field="nickname">昵称</th>
                        <th data-field="adminRole.name">角色</th>
                        <th data-field="option" data-formatter="actionFormatter" data-events="actionEvents">操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <div class="modal fade  bs-example-modal-lg" id="addAccount">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">新增帐号</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <div class="panel ">
                                <div class="panel-body">
                                    <form class="form-horizontal">
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">用户名：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input type="text" class="form-control" ng-model="account.userName">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">密码：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input type="text" class="form-control" ng-model="account.password">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">昵称：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input type="text" class="form-control" ng-model="account.nickname">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">角色：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <select class="form-control" ng-model="account.adminRoleId" ng-options="x.id as x.name for x in roles">
                                                       <option value="">全部</option>  
                                                        </select>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="accountSave()">保存</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade  bs-example-modal-lg" id="accountEdit">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">修改帐号</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <div class="panel ">
                                <div class="panel-body">
                                    <form class="form-horizontal">
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">用户名：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input type="hidden" class="form-control" ng-model="account.id">
                                                    <input type="text" class="form-control" ng-model="account.userName">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">昵称：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input type="text" class="form-control" ng-model="account.nickname">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">角色：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <select class="form-control" ng-model="account.adminRoleId" ng-options="x.id as x.name for x in roles">
                                                        </select>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="accountEdit()">保存</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade  bs-example-modal-lg" id="accountEditPass">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">修改密码</h4>
                </div>
                <form name="editPassForm" ng-submit="accountEditPass(editPassForm.$valid)" class="form-horizontal">
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="panel ">
                                    <div class="panel-body">
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">新密码：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input name="password" type="text" class="form-control" ng-model="account.password" required>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group">
                                                <label class="col-lg-2 col-md-2 control-label">确认密码：</label>
                                                <div class="col-lg-8 col-md-8">
                                                    <input name="rePassword" type="text" class="form-control" ng-model="account.rePassword" pw-check="password" required>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </form>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="delete">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">删除</h4>
                </div>
                <div class="modal-body"> 是否删除该帐号
                    <input type="hidden" ng-model="deleteId" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-danger" ng-click="deleteAccount()">是</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

</div>
<!-- /.container-fluid -->
<script>
function actionFormatter(value) {
          return [
            '<button class="btn btn-default edit">编辑</button>' ,
            '<button class="btn btn-default editPass"> 修改密码</button>' ,
            '<button class="btn btn-danger delete"> 删除</button>'
        ].join('');
    }

    window.actionEvents = {
        'click .edit': function (e, value, row) {
             var $scope = angular.element(document.querySelector('[ng-controller=backAccountCtrl]')).scope(); 
        },
        'click .editPass': function (e, value, row) {
            var $scope = angular.element(document.querySelector('[ng-controller=backAccountCtrl]')).scope(); 
        },
        'click .delete': function (e, value, row) {
          var $scope = angular.element(document.querySelector('[ng-controller=backAccountCtrl]')).scope(); 
        }
    };

</script>